type sourceType = string;

class Bitmap {
  source: sourceType;
  bitMap: ImageBitmap | undefined;
  constructor(source: sourceType) {
    this.source = source;

    this.create();
  }
  async create() {
    const img = new Image();
    img.src = this.source;
    img.onload = () => {
      Promise.resolve(createImageBitmap(img, 0, 0, 64, 64)).then((bitmap) => {
        this.bitMap = bitmap;
      });
    };
  }
  destory() {
    this.bitMap && this.bitMap.close();
  }
}

export default Bitmap;
